package com.cheer.param;

import com.cheer.dto.AccountDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@Data
@ApiModel("特殊推荐")
public class ApplicantSpecialParam {

    @NotNull(message = "组织机构Id不能为空")
    @ApiModelProperty("组织机构ID")
    private Long orgId;

    @NotBlank(message = "集体名称不能为空")
    @ApiModelProperty("集体名称")
    @Length(max = 20, message = "负责人不能超过20个字符")
    private String applicantName;

    @NotBlank(message = "手机号不能为空")
    @ApiModelProperty("手机号")
    @Length(max = 20, message = "手机号不能超过20个字符")
    private String phone;

    @Length(max = 20, message = "备用账号不能超过20个字符")
    private String backupAccount;

    @Length(max = 20, message = "密码不能超过20个字符")
    private String password;

    @Length(max = 20, message = "确认密码不能超过20个字符")
    private String confirmPassword;


    public AccountDTO build(Integer role) {
        AccountDTO accountDTO = new AccountDTO();
        accountDTO.setPhone(phone);
        accountDTO.setBackupAccount(backupAccount);
        accountDTO.setPassword(password);
        accountDTO.setRole(role);
        accountDTO.setSecurityQuestion("管理员负责人叫什么？");
        accountDTO.setSecurityAnswer(applicantName);
        return accountDTO;
    }


}
